package com.maixy.dailydemo.design.factory;

/**
 * @ClassName ProductFactory
 * @Description TODO
 * @Date 2021/4/20 9:49
 * @Author maixy
 */
public class ProductFactory extends FactoryMethod{
    @Override
    protected Product createProduct(String name) {
        if (EnumProductType.activityOne.getName().equals(name)) {
            return new OneProduct();
        } else if (EnumProductType.activityTwo.getName().equals(name)) {
            return new TwoProduct();
        } else {
            return null;
        }
    }

    public static class OneProduct extends Product {

    }

    public static class TwoProduct extends Product {

    }

    public static void main(String[] args) {
        FactoryMethod factoryMethod = new ProductFactory();
        Product product = factoryMethod.Product("one","one");
        System.out.println(product.getProductName());
    }
}
